package com.woniu.cinema.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.woniu.common.annotation.Log;
import com.woniu.common.core.controller.BaseController;
import com.woniu.common.core.domain.AjaxResult;
import com.woniu.common.enums.BusinessType;
import com.woniu.cinema.domain.MovieTypeRel;
import com.woniu.cinema.service.MovieTypeRelService;
import com.woniu.common.utils.poi.ExcelUtil;
import com.woniu.common.core.page.TableDataInfo;

/**
 * 影片和影片类型对应Controller
 * 
 * @author yy
 * @date 2023-09-27
 */
@RestController
@RequestMapping("/cinema/movietyperel")
public class MovieTypeRelController extends BaseController
{
    @Autowired
    private MovieTypeRelService movieTypeRelService;

    /**
     * 查询影片和影片类型对应列表
     */
    @GetMapping("/list")
    public TableDataInfo list(MovieTypeRel movieTypeRel)
    {
        startPage();
        List<MovieTypeRel> list = movieTypeRelService.selectMovieTypeRelList(movieTypeRel);
        return getDataTable(list);
    }

    /**
     * 导出影片和影片类型对应列表
     */
    @Log(title = "影片和影片类型对应", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MovieTypeRel movieTypeRel)
    {
        List<MovieTypeRel> list = movieTypeRelService.selectMovieTypeRelList(movieTypeRel);
        ExcelUtil<MovieTypeRel> util = new ExcelUtil<MovieTypeRel>(MovieTypeRel.class);
        return util.exportExcel(list, "movietyperel");
    }

    /**
     * 获取影片和影片类型对应详细信息
     */
    @GetMapping(value = "/{movieTypeId}")
    public AjaxResult getInfo(@PathVariable("movieTypeId") Integer movieTypeId)
    {
        return AjaxResult.success(movieTypeRelService.selectMovieTypeRelById(movieTypeId));
    }

    /**
     * 新增影片和影片类型对应
     */
    @Log(title = "影片和影片类型对应", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MovieTypeRel movieTypeRel)
    {
        return toAjax(movieTypeRelService.insertMovieTypeRel(movieTypeRel));
    }

    /**
     * 修改影片和影片类型对应
     */
    @Log(title = "影片和影片类型对应", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MovieTypeRel movieTypeRel)
    {
        return toAjax(movieTypeRelService.updateMovieTypeRel(movieTypeRel));
    }

    /**
     * 删除影片和影片类型对应
     */
    @Log(title = "影片和影片类型对应", businessType = BusinessType.DELETE)
	@DeleteMapping("/{movieTypeIds}")
    public AjaxResult remove(@PathVariable Integer[] movieTypeIds)
    {
        return toAjax(movieTypeRelService.deleteMovieTypeRelByIds(movieTypeIds));
    }
}
